# Maintainer: Leo <thinkabit.ukim@gmail.com>
pkgname=nerd-fonts
pkgver=2.1.0
pkgrel=5
pkgdesc="Iconic font aggregator, collection and patcher"
url="https://nerdfonts.com"
arch="noarch"
options="!check" # No testsuite provided
license="MIT"
subpackages="
	font-hermit-nerd:hermit:noarch
	font-ia-writer-nerd:writer:noarch
	font-terminus-nerd:terminus:noarch
	font-overpass-nerd:overpass:noarch
	font-ibm-plex-nerd:plex:noarch
	font-liberation-nerd:liberation:noarch
	font-ubuntu-nerd:ubuntu:noarch
	font-arimo-nerd:arimo:noarch
	font-source-code-pro-nerd:source_code:noarch
	font-cascadia-code-nerd:cascadia:noarch
	font-tinos-nerd:tinos:noarch
	font-hack-nerd:hack:noarch
	font-hasklig-nerd:hasklig:noarch
	font-anonymous-pro-nerd:anonymous:noarch
	font-share-tech-mono-nerd:share_tech:noarch
	font-space-mono-nerd:space:noarch
	font-go-mono-nerd:go:noarch
	font-iosevka-nerd:iosevka:noarch
	font-jetbrains-mono-nerd:jetbrains:noarch
	font-fira-mono-nerd:fira:noarch
	font-monofur-nerd:monofur:noarch
	font-inconsolata-nerd:inconsolata:noarch
	"
source="
	Hermit-$pkgver.zip::https://github.com/ryanoasis/nerd-fonts/releases/download/v$pkgver/Hermit.zip
	ia-Writer-$pkgver.zip::https://github.com/ryanoasis/nerd-fonts/releases/download/v$pkgver/iA-Writer.zip
	terminus-$pkgver.zip::https://github.com/ryanoasis/nerd-fonts/releases/download/v$pkgver/Terminus.zip
	overpass-$pkgver.zip::https://github.com/ryanoasis/nerd-fonts/releases/download/v$pkgver/Overpass.zip
	ibm-plex-$pkgver.zip::https://github.com/ryanoasis/nerd-fonts/releases/download/v$pkgver/IBMPlexMono.zip
	liberation-$pkgver.zip::https://github.com/ryanoasis/nerd-fonts/releases/download/v$pkgver/LiberationMono.zip
	ubuntu-$pkgver.zip::https://github.com/ryanoasis/nerd-fonts/releases/download/v$pkgver/Ubuntu.zip
	ubuntu-mono-$pkgver.zip::https://github.com/ryanoasis/nerd-fonts/releases/download/v$pkgver/UbuntuMono.zip
	arimo-$pkgver.zip::https://github.com/ryanoasis/nerd-fonts/releases/download/v$pkgver/Arimo.zip
	source-code-pro-$pkgver.zip::https://github.com/ryanoasis/nerd-fonts/releases/download/v$pkgver/SourceCodePro.zip
	cascadia-code-$pkgver.zip::https://github.com/ryanoasis/nerd-fonts/releases/download/v$pkgver/CascadiaCode.zip
	tinos-$pkgver.zip::https://github.com/ryanoasis/nerd-fonts/releases/download/v$pkgver/Tinos.zip
	hack-$pkgver.zip::https://github.com/ryanoasis/nerd-fonts/releases/download/v$pkgver/Hack.zip
	hasklig-$pkgver.zip::https://github.com/ryanoasis/nerd-fonts/releases/download/v$pkgver/Hasklig.zip
	anonymous-pro-$pkgver.zip::https://github.com/ryanoasis/nerd-fonts/releases/download/v$pkgver/AnonymousPro.zip
	share-tech-mono-$pkgver.zip::https://github.com/ryanoasis/nerd-fonts/releases/download/v$pkgver/ShareTechMono.zip
	space-mono-$pkgver.zip::https://github.com/ryanoasis/nerd-fonts/releases/download/v$pkgver/SpaceMono.zip
	go-mono-$pkgver.zip::https://github.com/ryanoasis/nerd-fonts/releases/download/v$pkgver/Go-Mono.zip
	iosevka-$pkgver.zip::https://github.com/ryanoasis/nerd-fonts/releases/download/v$pkgver/Iosevka.zip
	jetbrains-mono-$pkgver.zip::https://github.com/ryanoasis/nerd-fonts/releases/download/v$pkgver/JetBrainsMono.zip
	fira-mono-$pkgver.zip::https://github.com/ryanoasis/nerd-fonts/releases/download/v$pkgver/FiraMono.zip
	monofur-$pkgver.zip::https://github.com/ryanoasis/nerd-fonts/releases/download/v$pkgver/Monofur.zip
	inconsolata-$pkgver.zip::https://github.com/ryanoasis/nerd-fonts/releases/download/v$pkgver/Inconsolata.zip
	"
builddir="$srcdir"

package() {
	for pkg in $subpackages; do
		depends="$depends ${pkg%%:*}"
	done
	mkdir -p "$pkgdir"
}

_install_font_otf() {
	find "$srcdir" -iname "$1*otf" | while read -r otf; do
		echo "${otf##*/}" | grep -q 'Windows Compatible.otf' && continue
		echo "${otf##*/}"
		install -Dm644 "$otf" -t "$subpkgdir"/usr/share/fonts/OTF
	done
}

_install_font_ttf() {
	find "$srcdir" -iname "$1*ttf" | while read -r ttf; do
		echo "${ttf##*/}" | grep -Fq 'Windows Compatible.ttf' && continue
		echo "${ttf##*/}"
		install -Dm644 "$ttf" -t "$subpkgdir"/usr/share/fonts/TTF
	done
}

hermit() {
	depends="fontconfig"
	pkgdesc="$pkgdesc (Hermit)"
	_install_font_otf Hurmit
}

writer() {
	depends="fontconfig"
	pkgdesc="$pkgdesc (iA Writer)"
	_install_font_otf 'iM Writing'
	_install_font_ttf 'iM Writing'
}

terminus() {
	depends="fontconfig"
	pkgdesc="$pkgdesc (Terminus)"
	_install_font_ttf Terminess
}

overpass() {
	depends="fontconfig"
	pkgdesc="$pkgdesc (Overpass)"
	_install_font_otf Overpass
	_install_font_ttf Overpass
}

plex() {
	depends="fontconfig"
	pkgdesc="$pkgdesc (IBM Plex)"
	_install_font_ttf 'Blex Mono'
}

liberation() {
	depends="fontconfig"
	pkgdesc="$pkgdesc (Liberation)"
	_install_font_ttf Literation
}

ubuntu() {
	depends="fontconfig"
	pkgdesc="$pkgdesc (Ubuntu)"
	_install_font_ttf Ubuntu
}

arimo() {
	depends="fontconfig"
	pkgdesc="$pkgdesc (Arimo)"
	_install_font_ttf Arimo
}

source_code() {
	depends="fontconfig"
	pkgdesc="$pkgdesc (Source Code Pro)"
	_install_font_ttf 'Sauce Code Pro'
}

cascadia() {
	depends="fontconfig"
	pkgdesc="$pkgdesc (Cascadia Code)"
	_install_font_ttf Caskaydia
}

tinos() {
	depends="fontconfig"
	pkgdesc="$pkgdesc (Tinos)"
	_install_font_ttf Tinos
}

hack() {
	depends="fontconfig"
	pkgdesc="$pkgdesc (Hack)"
	_install_font_ttf Hack
}

hasklig() {
	depends="fontconfig"
	pkgdesc="$pkgdesc (Hasklig)"
	_install_font_otf Hasklug
}

anonymous() {
	depends="fontconfig"
	pkgdesc="$pkgdesc (Anonymous Pro)"
	_install_font_ttf Anonymice
}

share_tech() {
	depends="fontconfig"
	pkgdesc="$pkgdesc (Share Tech Mono)"
	_install_font_ttf 'Shure Tech Mono'
}

space() {
	depends="fontconfig"
	pkgdesc="$pkgdesc (Space Mono)"
	_install_font_ttf Space
}

go() {
	depends="fontconfig"
	pkgdesc="$pkgdesc (Go Mono)"
	_install_font_ttf 'Go Mono'
}

iosevka() {
	depends="fontconfig"
	pkgdesc="$pkgdesc (Iosevka)"
	_install_font_ttf Iosevka
}

jetbrains() {
	depends="fontconfig"
	pkgdesc="$pkgdesc (JetBrains Mono)"
	_install_font_ttf 'JetBrains Mono'
}

fira() {
	depends="fontconfig"
	pkgdesc="$pkgdesc (Fira Mono)"
	_install_font_otf 'Fira Mono'
}

monofur() {
	depends="fontconfig"
	pkgdesc="$pkgdesc (Monofur)"
	_install_font_ttf monofur
}

inconsolata() {
	depends="fontconfig"
	pkgdesc="$pkgdesc (Inconsolata)"
	_install_font_ttf Inconsolata
}

sha512sums="caf9026646ea1756c0c3d4f5ef08b2329ce10f6bfeefd7a4c7cfba1ac16c85e08103cd05fe4ba9c34fc6f35bb1a5a8830053dc5f90f153410fec12ef134bf84a  Hermit-2.1.0.zip
6fc219e954295fe4cc1a778141aa464f2b08d73def4c3428e875502d7c1cce1f2d5a4f178a83641e1e4b5d5c45eb406f11ab7858723894dd0bf4ec5e08775adf  ia-Writer-2.1.0.zip
9189ac650b258528f51fa83d5bdd0c8f165c969d00b5a82ccdaf824684de188c8db10f92eb125591351aefcf1012cf198a07c643b3b8a3a7c2c8074e143cc926  terminus-2.1.0.zip
f16a963cd65f4ebe23918571ffd49c1a0fca315040012d1600a3292e6a79a2c88181ddc5a252329c4edcc8a5b5bc3d08d23c8e12f36f469b2a8856345bef33ea  overpass-2.1.0.zip
a4d6038e2c87cd481e29204adfb870b7af996d56a101bf7b8ef56682083888a63f48109c6d0be0b9b81ea2ebb6ce7e9c9ee0ad8006fed806ff3f9e4c6ddefe67  ibm-plex-2.1.0.zip
9a2fbd17c9af420b27dccbd6f4e3e2af133cce91e549d8427d8a8d78e825e1b79495884c18c13b189e7a8d7b58bb3e7029e132ac6d79cac3cf0406d44e6f05c8  liberation-2.1.0.zip
ae939dff1d3854c7945f21b520e8cd8b5fa143f861e5911be492d1cad14a9cfc07e77ce2314af093702ab2ebbbfee7f69ac8faf95b8cc96cad257452870faf03  ubuntu-2.1.0.zip
32b8bd58f95552d9d7b50bf8047d5025d240f7f1ea99826c0257427a4a4c7bf811517bfb2416c1adfc2379429455c0b06fcbc401b46ee9b09b0249d64f44a2fa  ubuntu-mono-2.1.0.zip
c947c27766fd5f4725792d5745cc405b268f9c326da260c97af80ee729443ff39ad9a97fc4f122143ab2306fddedd5e8b55c13e4b3d90d3f65bf4d8559742dc1  arimo-2.1.0.zip
550884cd0b4ac89e3a63434f636548e468a68763eeebb378ce3ab23971ae68bf3d3bd825cdc2634340da05e1b3712a3220c6cf875c36d946430add216cbfe709  source-code-pro-2.1.0.zip
43422e7b075a8ae2d9eb77c5bf05cb26c590a1ac288731bdfb84dd1619038a0dd011546f1bcea7c436bc50d25a0a87cb7158c50eb37ed856bfa8757409b9259a  cascadia-code-2.1.0.zip
9ffa9b3689eddf5f2f22ac36018d0ac7c7cf26ffbc31b6865d7f316dd25f345480425cfc5488e5ac0866b7db5ead727dbf28a711b89c4af04d5a2d05a5bf3550  tinos-2.1.0.zip
fa545a32df4a94ba760378835d3b1d819a099d938a8dbfdc02d7712653a62893c7c1d67cd465ae96f2d8fe0b6094b5134c7342325e776709ac44749baef562e5  hack-2.1.0.zip
42e28b895795b3d1045265e6a9ea910103c2ad1f2ce88fdc21fefbf4db1e2fd46ab7e8e83417a5d8990041cae515e477b2d911a9603a4b55d81e0acc4797d832  hasklig-2.1.0.zip
761bb318e2f1a2f139c92aa793cf90156f892103233441632d88b13c6aa02c98f8704ecf510d44f9e9f7435896d16a81d720d65d1cd225c20271d769fd11305e  anonymous-pro-2.1.0.zip
731dee4a8b9fcf399495b858378dd34746f2e5a9ed67e69e98387c5e77af7342df518221327264c207d75df5cfd878734aecc6fc3b170cf2972d39083bec597d  share-tech-mono-2.1.0.zip
9c0abc645b0db737f6f648d0d93f5fab1c7d0cb2e5d99e57de3476c61006a40faa430c6c1cc4cf23164d8e219c0419175e61b45b1780c7c43069aa0c89bb32eb  space-mono-2.1.0.zip
27eed9df1161564db22278b88492e30976dfbc8783bcfda6324c3dad3246f5d1466b2d318b7fbaa641baf410afbc7b362f310e410484dbead9d2f0e73de03ea1  go-mono-2.1.0.zip
f97624aa018012313d1b496629a0db42c6b7f23eb473d71791445bbb7e1662335f846a37ee90d162e3eefee429169dd059407db0270ef5f327b9053e61417d8c  iosevka-2.1.0.zip
effc1a81670c37b07f17f1c756a480091c777f6074b59cd6eefd09c8d5210b529de3c41e9cedf4992aacd9fe5bb3a5b331411bfe5b2b6f0eb8680a8e852247c2  jetbrains-mono-2.1.0.zip
7bf6bed10d044ff487cc4c0137159180dc150fbb827e87359d89a29cc0eb9e6484b40434968a4c6ba96e2d54933db826b5f2d7f421ba914decda5c2d3497803e  fira-mono-2.1.0.zip
392df23757ceff77278dda9afb7820a8807fbbc46dd1c1b46486fc697891b8b9dcc63288b64c83187b140bf85443fe8d1bbc8d0d0497ca1be0d6aa11d99f5ed5  monofur-2.1.0.zip
c6b3a896543fb92df8ad0f8e3aede04ed5f17a3f61bcaf8146e8c0d872cb1a985226cd7062487a95f23ab168fdd5c8f4d7edf8818571c6e7dc3b9f4a0069e34d  inconsolata-2.1.0.zip"
